package org.haredot.web;

public class ResponseEntity {
    /**
     * 要下载的资源
     */
    private byte[] bytes;
    /**
     * 下载的媒体类型
     */
    private String contentType;

    /**
     * 是否采用附件形式
     */
    private boolean attachment;
    /**
     * 下载的文件名
     */
    private String filename;

    public byte[] getBytes() {
        return bytes;
    }

    public void setBytes(byte[] bytes) {
        this.bytes = bytes;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public boolean isAttachment() {
        return attachment;
    }

    public void setAttachment(boolean attachment) {
        this.attachment = attachment;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public static ResponseEntityBuilder builder() {
        return new ResponseEntityBuilder();
    }

    public static class ResponseEntityBuilder {

        private ResponseEntity responseEntity = new ResponseEntity();

        public ResponseEntityBuilder contentType(String contentType) {
            responseEntity.setContentType(contentType);
            return this;
        }

        public ResponseEntityBuilder attachment(boolean attachment) {
            responseEntity.setAttachment(attachment);
            return this;
        }

        public ResponseEntityBuilder filename(String filename) {
            responseEntity.setFilename(filename);
            return this;
        }

        public ResponseEntity body(byte[] bytes) {
            responseEntity.setBytes(bytes);
            return responseEntity;
        }
    }
}
